import datetime
import time
from functools import wraps

import cv2
from PyQt5 import QtGui


def log(*text):
    text = str(datetime.datetime.now())[:19] + '--' + ', '.join([str(i) for i in text])
    print(text)
    return text + '\n\n'


def fn_timer(function):
    @wraps(function)
    def function_timer(*args, **kwargs):
        t0 = time.time()
        result = function(*args, **kwargs)
        t1 = time.time()
        log("Total time running %s: %.2f seconds" %
            (function.__name__, t1 - t0)
            )
        return result

    return function_timer


